﻿Imports System.Data.SqlClient

Module HR_Utilities

    Public Sub PrintStaffProfile(ByVal EmpID As Integer)
        Try
            Dim dap As New SqlDataAdapter(" Select * From StaffProfiles where EmpNo= " & EmpID, cnn)
            Dim dt As New DataTable
            dap.Fill(dt)

            Dim rpt As New StaffProfile
            rpt.SetDataSource(dt)
            rptViewer.CrystalReportViewer1.ReportSource = rpt
            rptViewer.CrystalReportViewer1.RefreshReport()
            rptViewer.ShowDialog()

            rpt.Dispose()
        Catch ex As Exception
            If cnn.State = ConnectionState.Open Then
                cnn.Close()
            End If
            MsgBox(ex.ToString)
        End Try
    End Sub

    Public Sub PrintStaffAppraisalForm(ByVal MoveNo As Integer)
        Try
            Dim dap As New SqlDataAdapter(" Select * From StaffAppraisalForm where MoveNo=" & MoveNo, cnn)
            Dim dt As New DataTable
            dap.Fill(dt)

            Dim rpt As New StaffAppraisalForm
            rpt.SetDataSource(dt)
            rptViewer.CrystalReportViewer1.ReportSource = rpt
            rptViewer.CrystalReportViewer1.RefreshReport()
            rptViewer.ShowDialog()

            rpt.Dispose()
        Catch ex As Exception
            If cnn.State = ConnectionState.Open Then
                cnn.Close()
            End If
            MsgBox(ex.ToString)
        End Try
    End Sub

    Public Sub PrintWorning(ByVal SNo As Integer)
        Try
            Dim das As New DataSet
            Dim dap As New SqlDataAdapter("Select * From Wornings Where SNo=" & SNo, cnn)

            dap.Fill(das, "Wornings")

            Dim rpt As New rptWorning
            rpt.SetDataSource(das)
            rptViewer.CrystalReportViewer1.ReportSource = rpt
            rptViewer.ShowDialog()

            rpt.Dispose()
        Catch ex As Exception
            If cnn.State = ConnectionState.Open Then
                cnn.Close()
            End If
            MsgBox(ex.ToString)
        End Try
    End Sub

    Public Sub PrintJobOffer(ByVal SNo As Integer)
        Try
            Dim dap As New SqlDataAdapter("Select * From JobOffers JobOffers Where SNo=" & SNo, cnn1)
            Dim das As New DataSet

            dap.Fill(das, "JobOffers")

            Dim rpt As New JopOffer
            rpt.SetDataSource(das)
            ReportViewer.CrystalReportViewer1.ReportSource = rpt
            ReportViewer.ShowDialog()
        Catch ex As Exception
            MsgBox(ex.ToString)
        Finally
            If cnn1.State = ConnectionState.Open Then
                cnn1.Close()
            End If
        End Try
    End Sub
End Module
